import { Controller, Post, Get, Body, Query } from '@nestjs/common';
import { IndicatorService } from './indicator.service';
import {
  AddIndicatorDto,
  GetIndicatorPageTreeDto,
  GetIndicatorPageDto,
  DeleteIndicatorDto,
  GetIndicatorTagIndexListDto,
  CheckFormulaDto,
} from './indicator.dto'

@Controller('data/indicator')
export class IndicatorController {
  constructor(private readonly indicatorService: IndicatorService) {
    this.onApplicationBootstrapIndicatorTask()
  }

  @Post('add')
  addIndicator(@Body() addIndicatorDto: AddIndicatorDto) {
    return this.indicatorService.addIndicator(addIndicatorDto)
  }

  @Post('update')
  updateIndicator() {
    return this.indicatorService.updateIndicator()
  }

  @Get('page')
  getIndicatorPageTree(@Query() getIndicatorPageTreeDto: GetIndicatorPageTreeDto) {
    return this.indicatorService.getIndicatorPageTree(getIndicatorPageTreeDto)
  }

  @Post('pageTable')
  getIndicatorPage(@Body() getIndicatorPageDto: GetIndicatorPageDto) {
    return this.indicatorService.getIndicatorPage(getIndicatorPageDto)
  }

  @Get('list')
  getIndicatorList() {
    return this.indicatorService.getIndicatorList()
  }

  @Get('info')
  getIndicatorInfo(@Query('id') id: string) {
    return this.indicatorService.getIndicatorInfo(id)
  }

  @Post('delete')
  deleteIndicator(@Body() deleteIndicatorDto: DeleteIndicatorDto) {
    return this.indicatorService.deleteIndicator(deleteIndicatorDto)
  }

  @Get('tagIndex/list')
  getIndicatorTagIndexList(@Query() getIndicatorTagIndexListDto: GetIndicatorTagIndexListDto) {
    return this.indicatorService.getIndicatorTagIndexList(getIndicatorTagIndexListDto)
  }

  @Post('checkFormula')
  checkFormula(@Body() checkFormulaDto: CheckFormulaDto) {
    return this.indicatorService.checkFormula(checkFormulaDto)
  }

  @Get('expression')
  expressionIndicator() {
    return this.indicatorService.expressionIndicator()
  }

  onApplicationBootstrapIndicatorTask() {
    this.indicatorService.indicatorTask()
  }
}
